﻿ import Taro, { Component } from '@tarojs/taro'
import Index from './pages/index'
import CommonJs from './utils/common'

// 如果需要在 h5 环境中开启 React Devtools
// 取消以下注释：
// if (process.env.NODE_ENV !== 'production' && process.env.TARO_ENV === 'h5')  {
//   require('nerv-devtools')
// }

//系加直播配置

class App extends Component {
  globalData = {
    isIphoneX: 0
  }
 
  
  config = {
  	"permission": {
       "scope.userLocation": {
       "desc": "你的位置信息将用于小程序位置接口的展示"
      }
     },
 plugins: {
         "live-player-plugin": {
           "version": "1.0.2",  
           "provider":"wx2b03c6e691cd7370"
       }
		 },
    pages: [
    	'pages/xijia/grouplist',
    	'pages/xijia/gxl',
	    'pages/xijia/gxlist',
    	'pages/xijia/gxq',
    	'pages/xijia/gxc',
		  'pages/activity/activity',
		  'pages/index/index',
		  'pages/index/changegw',
		  'pages/login/login',
		  'pages/login/read',
		  'pages/login/login_mobile',
		  'pages/chat/chat',
		  'pages/chat/syslist',
		  'pages/activitydetails/activitydetails',
		  'pages/activitybm/activitybm',
		  'pages/info/info',
		  'pages/persinfo/persinfo',
		  'pages/grouplist/grouplist',
		  'pages/grouplist/grouplists',
		  'pages/zhibo/index',
		  'pages/zhibo/history',
		  'pages/shop/index',
		  'pages/map/citylist'
    ],
    window: { 
      backgroundTextStyle: 'light',
      navigationBarBackgroundColor: '#fff',
      navigationBarTitleText: 'WeChat',
      navigationBarTextStyle: 'black' 
    },
	subPackages:[
	  {
      "root": "pages/mall/",
      "pages": ['index','goodsxq','shopcar','order','goodscat','goodslist','yhq','yhqcenter','shopindex','ucindex','wucindex','shop','ucmall']
      },
      {
      	"root": "pages/card/",
        "pages": ['index','cardadd','cardlist']
      },
      {
      	"root": "pages/mybill/",
        "pages": ['mybill','mybuy']
      },
      {
      	"root": "pages/coupon/",
        "pages": ['coupon','details']
      },
      {
      	"root": "pages/pkgo/",
        "pages": ['pkgo','pkgodetails','confirmorder','confirmorders','lottery','winningrecord','goodsdetails','invitepk','invitespk']
      },
      {
      	"root": "pages/my/",
        "pages": ['my','tx','txlist','bank','bankadd','wlinfo','unpaid','activety','activety1','address','region','accountdetails','pointsdetails','recharge','dollardetails','consumer','ziqia','xingyong','wdt','xflist','gxjlist','xfjlist','myewm','bigcharge','zrcapital','homeset','pwdset','jiazhi','zxzc','xypage']
      },
      {
      	"root": "pages/tuiguang/",
        "pages": ['index','enter']
      },
      {
      	"root": "pages/cloud/",
        "pages": ['cgorder','cggoods','xsorder','shangjia','cgrecord']
      },
      {
      	"root": "pages/join/",
        "pages": ['index','shoptype','pay','qydetail']
      },
      {
      	"root": "pages/news/",
        "pages": ['newimg','newtitle']
      },
      {
      	"root": "pages/hongbao/",
        "pages": ['record']
      }
    ] 
  }


  componentWillMount () { 
  	Taro.setStorage({key:'webinfo',data:''})
//	const accountInfo = Taro.getAccountInfoSync();
//		const appid=accountInfo.miniProgram.appId;
//		var url='/advert/papi/v1.9/apply-setting/identification/'+appid
//		CommonJs.ajaxRequest(url,'','GET',function(res){
//			if(res.data){
//				var obj={};
//				obj.webname=res.data.applyName
//				obj.logo=res.data.logo
//				obj.dealerId=res.data.dealerId
//				obj.dealerName=res.data.dealerName
//				obj.iszb=res.data.liveOpenStatus
//				Taro.setStorage({key:'webinfo',data:obj})
//			}
//		})
		var _this=this;
  	Taro.getSystemInfo({
      success: res => {
        let modelmes = res.model;
        console.log(JSON.stringify(res.model))
        let iphoneArr = ['iPhone X', 'iPhone 11', 'iPhone 11 Pro Max']
        iphoneArr.forEach(function (item) {
          if (modelmes.search(item) != -1) {
            _this.globalData.isIphoneX = 1
          }
          
        })    
      }
   })
  }
  componentDidMount () {
  	var cid=''
  	if(this.$router.params&&this.$router.params.query){
  		if(this.$router.params.query.scene){
  			cid=this.$router.params.query.scene
  			this.$preload({
		  		type:1,
		  		qid:cid
		  	})
		
		  		var dateinfo=Taro.getStorageSync('dateinfo')
		  		if(dateinfo){
		  			dateinfo.qid=cid
		  		}
		  		else{
				  	dateinfo={
				  		qid:cid
				    }
				  }
		  	Taro.setStorage({key:'dateinfo',data:dateinfo})
  		}
  	}
  }

  componentDidShow () {}

  componentDidHide () {

  }

  componentDidCatchError () {}

  // 在 App 类中的 render() 函数没有实际作用
  // 请勿修改此函数
  render () {
  	
    return (
      <Index />
    )
  }
}

Taro.render(<App />, document.getElementById('app'))